jQuery.fn.extend({
    everyTime: function (a, b, c, d, e) {
        return this.each(function () {
            jQuery.timer.add(this, a, b, c, d, e)
        })
    },
    oneTime: function (a, b, c) {
        return this.each(function () {
            jQuery.timer.add(this, a, b, c, 1)
        })
    },
    stopTime: function (a, b) {
        return this.each(function () {
            jQuery.timer.remove(this, a, b)
        })
    }
});
jQuery.extend({
    timer: {
        global: [],
        guid: 1,
        dataKey: "jQuery.timer",
        regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
        powers: {
            'ms': 1,
            'cs': 10,
            'ds': 100,
            's': 1000,
            'das': 10000,
            'hs': 100000,
            'ks': 1000000
        },
        timeParse: function (a) {
            if (a == undefined || a == null) return null;
            var b = this.regex.exec(jQuery.trim(a.toString()));
            if (b[2]) {
                var c = parseFloat(b[1]);
                var d = this.powers[b[2]] || 1;
                return c * d
            } else {
                return a
            }
        },
        add: function (a, b, c, d, e, f) {
            var g = 0;
            if (jQuery.isFunction(c)) {
                if (!e) e = d;
                d = c;
                c = b
            }
            b = jQuery.timer.timeParse(b);
            if (typeof b != 'number' || isNaN(b) || b <= 0) return;
            if (e && e.constructor != Number) {
                f = !! e;
                e = 0
            }
            e = e || 0;
            f = f || false;
            var h = jQuery.data(a, this.dataKey) || jQuery.data(a, this.dataKey, {});
            if (!h[c]) h[c] = {};
            d.timerID = d.timerID || this.guid++;
            var i = function () {
                if (f && this.inProgress) return;
                this.inProgress = true;
                if ((++g > e && e !== 0) || d.call(a, g) === false) jQuery.timer.remove(a, c, d);
                this.inProgress = false
            };
            i.timerID = d.timerID;
            if (!h[c][d.timerID]) h[c][d.timerID] = window.setInterval(i, b);
            this.global.push(a)
        },
        remove: function (a, b, c) {
            var d = jQuery.data(a, this.dataKey),
                ret;
            if (d) {
                if (!b) {
                    for (b in d) this.remove(a, b, c)
                } else if (d[b]) {
                    if (c) {
                        if (c.timerID) {
                            window.clearInterval(d[b][c.timerID]);
                            delete d[b][c.timerID]
                        }
                    } else {
                        for (var c in d[b]) {
                            window.clearInterval(d[b][c]);
                            delete d[b][c]
                        }
                    }
                    for (ret in d[b]) break;
                    if (!ret) {
                        ret = null;
                        delete d[b]
                    }
                }
                for (ret in d) break;
                if (!ret) jQuery.removeData(a, this.dataKey)
            }
        }
    }
});
jQuery(window).bind("unload", function () {
    jQuery.each(jQuery.timer.global, function (a, b) {
        jQuery.timer.remove(b)
    })
});
(function ($) {
    $.fn.customFadeIn = function (a, b) {
        $(this).fadeIn(a, function () {
            if (!$.support.opacity) $(this).get(0).style.removeAttribute('filter');
            if (b != undefined) b()
        })
    };
    $.fn.customFadeOut = function (a, b) {
        $(this).fadeOut(a, function () {
            if (!$.support.opacity) $(this).get(0).style.removeAttribute('filter');
            if (b != undefined) b()
        })
    };
    $.fn.customFadeTo = function (a, b, c) {
        return this.animate({
            opacity: b
        }, a, function () {
            if (b == 1 && jQuery.browser.msie) this.style.removeAttribute('filter');
            if (jQuery.isFunction(c)) c()
        })
    }
})(jQuery);
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d)
    },
    easeInQuad: function (x, t, b, c, d) {
        return c * (t /= d) * t + b
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b
    },
    easeInCubic: function (x, t, b, c, d) {
        return c * (t /= d) * t * t + b
    },
    easeOutCubic: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b
    },
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b
    },
    easeInQuart: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b
    },
    easeOutQuart: function (x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b
    },
    easeInOutQuart: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b
    },
    easeInQuint: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b
    },
    easeInSine: function (x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b
    },
    easeOutSine: function (x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b
    },
    easeInOutSine: function (x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b
    },
    easeInCirc: function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b
    },
    easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b
    },
    easeInOutCirc: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b
    },
    easeInElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d) == 1) return b + c;
        if (!p) p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b
    },
    easeOutElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d) == 1) return b + c;
        if (!p) p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b
    },
    easeInOutElastic: function (x, t, b, c, d) {
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) return b;
        if ((t /= d / 2) == 2) return b + c;
        if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b
    },
    easeInBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b
    },
    easeOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b
    },
    easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b
    },
    easeInBounce: function (x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b
    },
    easeOutBounce: function (x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b
        }
    },
    easeInOutBounce: function (x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b
    }
});
var window_loaded = false;
(function ($) {
    $.fn.galleryView = function (w) {
        var z = w;
        var A;
        var B = 0;
        var C = 0;
        var D = 0;
        var E;
        var F;
        var G = false;
        var H = false;
        var I = true;
        var J = false;
        var K = false;
        var L;
        var M;
        var N;
        var O;
        var P;
        var Q;
        var R;
        var S;
        var T;
        var U = 20;
        var V;
        var W;
        var X;
        var Y = new Object();
        var Z = new Object();
        var bm = new Object();
        var bn = new Object();
        var bo = true;
        var bp = false;
        var bq;
        var br;
        var bs;
        var bt;
        var bu;
        var bv;
        var bw;
        var bx, mouseY;

        function showItem(i) {
            $('.nav-next-overlay', bq).unbind('click');
            $('.nav-prev-overlay', bq).unbind('click');
            $('.nav-next', bq).unbind('click');
            $('.nav-prev', bq).unbind('click');
            bs.unbind('click');
            if (z.panel_gradient) {
                var g = $("img", bu.eq(i % C)).attr("alt");
                $(".gallery_gradient", bq).unbind('click');
                switch (z.panel_on_click) {
                    case 'link-newwindow':
                        if (g != "") {
                            $(".gallery_gradient", bq).click(function () {
                                window.open(g);
                                return false
                            })
                        }
                        break;
                    case 'link-current':
                        if (g != "") {
                            $(".gallery_gradient", bq).click(function () {
                                location.href = g;
                                return false
                            })
                        }
                        break;
                    case 'viewfull':
                        $(".gallery_gradient", bq).click(function () {
                            var b = !G;
                            pause();
                            var c = $("img", bu.eq(i % C)).attr("src");
                            var d = c.substring(c.length - 3, c.length);
                            var e = $('.panel-overlay', bu.eq(i % C)).html();
                            c = c.substring(0, c.length - 4) + "_org." + d;
                            var a = $("<a href='" + c + "' title='" + e + "'>TEMP</a>");
                            var f = {
                                imageLoading: F + '/lightbox/lightbox-ico-loading.gif',
                                imageBtnPrev: F + '/lightbox/lightbox-btn-prev.gif',
                                imageBtnNext: F + '/lightbox/lightbox-btn-next.gif',
                                imageBtnClose: F + '/lightbox/lightbox-btn-close.gif',
                                imageBlank: F + '/lightbox/lightbox-blank.gif'
                            };
                            if (b) {
                                f.onClose = play
                            };
                            a.lightBox(f);
                            a.trigger('click')
                        });
                        break;
                    default:
                        break
                }
            }
            if (z.show_filmstrip) {
                bs.removeClass('current').find('img').stop().animate({
                    'opacity': z.frame_opacity
                }, z.transition_speed);
                bs.eq(i).addClass('current').find('img').stop().animate({
                    'opacity': 1.0
                }, z.transition_speed)
            }
            if (z.show_panels && z.fade_panels) {
                if (z.show_captions) {
                    switch (z.text_transition_effect) {
                        case 'blur':
                            var h = $('.panel-overlay', bu.eq(i % C)).html();
                            $('.overlay-content-panel', bq).html("");
                            $('.overlay-content-panel', bq).html("<div style='display:none' class='content'>" + h + "</div>");
                            $('.content', $('.overlay-content-panel', bq)).fadeIn(z.transition_speed);
                            break;
                        case 'push-left':
                        case 'push-right':
                            var h = $('.panel-overlay', bu.eq(i % C)).html();
                            var j = $('.overlay-content-panel', bq);
                            j.html("");
                            j.html("<div style='display:none' class='content'>" + h + "</div>");
                            $('.content', j).css({
                                'position': 'absolute',
                                'width': (z.caption_thickness - caption_overlay_padding) + 'px',
                                'left': (z.text_transition_effect == 'push-left' ? -z.caption_thickness - caption_overlay_padding : z.caption_thickness + caption_overlay_padding),
                                'display': 'block'
                            }).animate({
                                'left': 0
                            }, z.transition_speed);
                            break
                    }
                }
                var k = function () {
                    if (!z.show_filmstrip) {
                        $('.nav-prev-overlay', bq).click(showPrevItem);
                        $('.nav-next-overlay', bq).click(showNextItem);
                        $('.nav-prev', bq).click(showPrevItem);
                        $('.nav-next', bq).click(showNextItem)
                    } else {
                        enableFrameClicking()
                    }
                };
                var l = z.image_transition_effect;
                if (z.image_transition_effect == 'random') {
                    var m = new Array("blur", "slice-down-left", "slice-down-right", "slice-up-left", "slice-up-right", "slice-up-down");
                    l = m[Math.floor(Math.random() * (m.length + 1))];
                    if (l == undefined) l = 'blur'
                }
                switch (l) {
                    case 'blur':
                        bu.fadeOut(z.transition_speed).eq(i % C).fadeIn(z.transition_speed, k);
                        break;
                    case 'push-left':
                    case 'push-right':
                        if ((i % C) != B) {
                            bu.eq(i % C).show();
                            bu.css({
                                'opacity': 0
                            });
                            bu.eq(B).css({
                                'opacity': 1
                            });
                            bu.eq(B).animate({
                                'left': (l == 'push-left' ? L : -L) + 'px'
                            }, z.transition_speed, z.easing, function () {
                                $(this).css({
                                    'left': '0px',
                                    'opacity': 0
                                })
                            });
                            bu.eq(i % C).css({
                                'left': (l == 'push-left' ? -L : L) + 'px',
                                'opacity': 1
                            }).animate({
                                'left': '0px'
                            }, z.transition_speed, z.easing, k)
                        }
                        break;
                    case 'slice-down-left':
                    case 'slice-down-right':
                    case 'slice-up-left':
                    case 'slice-up-right':
                    case 'slice-up-down':
                        var n = 0;
                        var o = 0;
                        var p = $('.bj-slice', bq);
                        bu.fadeOut(0).eq(i % C).fadeIn(z.transition_speed);
                        o = 0;
                        var q = Math.round(z.panel_width / z.slices);
                        p.each(function () {
                            var a = $(this);
                            var b = $("img", bu.eq(B)).attr("src");
                            a.css({
                                background: 'url(' + b + ') no-repeat -' + (o * q) + 'px 0%'
                            });
                            o++
                        });
                        var r = '100%';
                        if (l == 'slice-down-right' || l == 'slice-up-right') {
                            p._reverse()
                        }
                        if (l == 'slice-up-left' || l == 'slice-up-right') {
                            r = '-100%'
                        }
                        o = 0;
                        p.each(function (a) {
                            var b = $(this);
                            if (o == z.slices - 1) {
                                setTimeout(function () {
                                    if (l == 'slice-up-down') {
                                        if (a % 2 == 0) {
                                            r = '100%'
                                        } else {
                                            r = '-100%'
                                        }
                                    }
                                    b.animate({
                                        top: r,
                                        opacity: '0'
                                    }, z.transition_speed, '', resetSlices)
                                }, (100 + n))
                            } else {
                                setTimeout(function () {
                                    if (l == 'slice-up-down') {
                                        if (a % 2 == 0) {
                                            r = '100%'
                                        } else {
                                            r = '-100%'
                                        }
                                    }
                                    b.animate({
                                        top: r,
                                        opacity: '0'
                                    }, z.transition_speed)
                                }, (100 + n))
                            }
                            n += 50;
                            o++
                        });
                        break
                }
            }
            if (z.show_filmstrip) {
                if (D == 0) {
                    if (i < strip_size - 1) E = 'pointer';
                    else E = 'strip'
                } else if (D == C - strip_size) {
                    if (i > D) E = 'pointer';
                    else E = 'strip'
                } else {
                    if (i > D && i < D + strip_size - 1) E = 'pointer';
                    else E = 'strip'
                }
                if (E == 'strip') {
                    br.stop();
                    if (X == 'horizontal') {
                        var s = 0;
                        var t = 0;
                        if (i > B) {
                            if (i < C - 1) {
                                s = (getPos(bs[D + strip_size - 1]).left) - getPos(bs[i - 1]).left;
                                t = (getPos(bs[D + strip_size - 2]).left - (O / 2) + (S / 2))
                            } else {
                                s = getPos(bs[i]).left - (getPos(bs[D + strip_size - 1]).left);
                                t = (getPos(bs[D + strip_size - 1]).left - (O / 2) + (S / 2))
                            }
                        } else {
                            if (i > 0) {
                                s = getPos(bs[i - 1]).left - (getPos(bs[D]).left);
                                t = (getPos(bs[D + 1]).left - (O / 2) + (S / 2))
                            } else {
                                s = getPos(bs[0]).left - (getPos(bs[D]).left);
                                t = (getPos(bs[D]).left - (O / 2) + (S / 2))
                            }
                        }
                        var u = (s >= 0 ? '-=' : '+=') + Math.abs(s) + 'px';
                        bv.animate({
                            'left': (t + 'px')
                        }, z.transition_speed, 'swing', function () {});
                        br.animate({
                            'left': u
                        }, z.transition_speed, 'swing', function () {
                            if (i < B) if (i == 0) D = 0;
                                else D = i - 1;
                                else if (i < C - 1) D = i + 2 - strip_size;
                            else D = C - strip_size;
                            B = i;
                            if (!z.fade_panels) {
                                bu.hide().eq(i % C).show()
                            }
                            $('.nav-prev-overlay', bq).click(showPrevItem);
                            $('.nav-next-overlay', bq).click(showNextItem);
                            $('.nav-prev', bq).click(showPrevItem);
                            $('.nav-next', bq).click(showNextItem)
                        })
                    } else {
                        var s = getPos(bs[i]).top - (getPos(bv[0]).top + (N) - (T / 2));
                        var u = (s >= 0 ? '-=' : '+=') + Math.abs(s) + 'px';
                        br.animate({
                            'top': u
                        }, z.transition_speed, 'swing', function () {
                            var a = i;
                            if (i > C) {
                                i = i % C;
                                B = i;
                                br.css('top', '-' + ((T + z.frame_gap) * i) + 'px')
                            } else if (i <= (C - strip_size)) {
                                i = (i % C) + C;
                                B = i;
                                br.css('top', '-' + ((T + z.frame_gap) * i) + 'px')
                            }
                            if (a != i) {
                                bs.eq(a).removeClass('current').find('img').css({
                                    'opacity': z.frame_opacity
                                });
                                bs.eq(i).addClass('current').find('img').css({
                                    'opacity': 1.0
                                })
                            }
                            if (!z.fade_panels) {
                                bu.hide().eq(i % C).show()
                            }
                            $('.nav-prev-overlay', bq).click(showPrevItem);
                            $('.nav-next-overlay', bq).click(showNextItem);
                            $('.nav-prev', bq).click(showPrevItem);
                            $('.nav-next', bq).click(showNextItem)
                        })
                    }
                } else if (E == 'pointer') {
                    bv.stop();
                    var v = getPos(bs[i]);
                    if (X == 'horizontal') {
                        bv.animate({
                            'left': (v.left + (S / 2) - (O / 2) + 'px')
                        }, z.transition_speed, 'swing', function () {
                            B = i;
                            if (!z.fade_panels) {
                                bu.hide().eq(i % C).show()
                            }
                            $('.nav-prev-overlay', bq).click(showPrevItem);
                            $('.nav-next-overlay', bq).click(showNextItem);
                            $('.nav-prev', bq).click(showPrevItem);
                            $('.nav-next', bq).click(showNextItem)
                        })
                    } else {
                        bv.animate({
                            'top': (v.top + (T / 2) - (N) + 'px')
                        }, z.transition_speed, 'swing', function () {
                            if (!z.fade_panels) {
                                bu.hide().eq(i % C).show()
                            }
                            $('.nav-prev-overlay', bq).click(showPrevItem);
                            $('.nav-next-overlay', bq).click(showNextItem);
                            $('.nav-prev', bq).click(showPrevItem);
                            $('.nav-next', bq).click(showNextItem)
                        })
                    }
                }
            } else {
                if (i < B) if (i == 0) D = 0;
                    else D = i - 1;
                    else if (i < C - 1) D = i + 2 - strip_size;
                else D = C - strip_size;
                B = i
            }
        };

        function extraWidth(a) {
            if (!a) return 0;
            if (a.length == 0) return 0;
            a = a.eq(0);
            var b = 0;
            b += getInt(a.css('paddingLeft'));
            b += getInt(a.css('paddingRight'));
            b += getInt(a.css('borderLeftWidth'));
            b += getInt(a.css('borderRightWidth'));
            return b
        }
        function extraHeight(a) {
            if (!a) return 0;
            if (a.length == 0) return 0;
            a = a.eq(0);
            var b = 0;
            b += getInt(a.css('paddingTop'));
            b += getInt(a.css('paddingBottom'));
            b += getInt(a.css('borderTopWidth'));
            b += getInt(a.css('borderBottomWidth'));
            return b
        }
        function play() {
            var a = $(".controller", bq);
            if (a.hasClass('playing')) {
                a.removeClass('playing').addClass('paused');
                a.attr('src', F + 'play.png');
                if (!G) {
                    $(document).oneTime(500, "animation_pause", function () {
                        $(document).stopTime("transition");
                        G = true
                    })
                }
            } else {
                a.removeClass('paused').addClass('playing');
                a.attr('src', F + 'pause.png');
                $(document).stopTime("animation_pause");
                if (G) {
                    $(document).everyTime(z.transition_interval, "transition", function () {
                        showNextItem()
                    });
                    G = false
                }
            }
        }
        function pause() {
            var a = $(".controller", bq);
            if (a != null) {
                a.removeClass('playing').addClass('paused');
                a.attr('src', F + 'play.png')
            }
            if (!G) {
                $(document).oneTime(500, "animation_pause", function () {
                    $(document).stopTime("transition");
                    G = true
                })
            }
        }
        function showNextItem() {
            $(document).stopTime("transition");
            if ((B + 1) == C) {
                showItem(0)
            } else showItem(B + 1);
            if (!G) {
                $(document).everyTime(z.transition_interval, "transition", function () {
                    showNextItem()
                })
            }
        };

        function showPrevItem() {
            $(document).stopTime("transition");
            if (B == 0) {
                showItem(C - 1)
            } else showItem(B - 1);
            if (!G) {
                $(document).everyTime(z.transition_interval, "transition", function () {
                    showPrevItem()
                })
            }
        };

        function getPos(a) {
            var b = 0,
                top = 0;
            var c = a.id;
            if (a.offsetParent) {
                do {
                    b += a.offsetLeft;
                    top += a.offsetTop
                } while (a = a.offsetParent)
            }
            if (c == A) {
                return {
                    'left': b,
                    'top': top
                }
            } else {
                var d = getPos(bq[0]);
                var e = d.left;
                var f = d.top;
                return {
                    'left': b - e,
                    'top': top - f
                }
            }
        };

        function enableFrameClicking() {
            bs.each(function (i) {
                if ($('a', this).length == 0) {
                    $(this).click(function () {
                        if (i != B) {
                            $(document).stopTime("transition");
                            showItem(i);
                            if (!G) {
                                $(document).everyTime(z.transition_interval, "transition", function () {
                                    showNextItem()
                                })
                            }
                        }
                    })
                }
            })
        };

        function buildPanels() {
            bu.each(function (i) {
                $(this).css({
                    'width': (z.panel_width - extraWidth(bu)) + 'px',
                    'height': (z.panel_height - extraHeight(bu)) + 'px',
                    'position': 'absolute'
                });
                $(this).css({
                    'top': 0 + 'px',
                    'left': '0px'
                });
                if (!z.panel_gradient) {
                    var g = $("img", $(this)).attr("alt");
                    switch (z.panel_on_click) {
                        case 'link-newwindow':
                            if (g != "") {
                                $(this).click(function () {
                                    window.open(g);
                                    return false
                                })
                            }
                            break;
                        case 'link-current':
                            if (g != "") {
                                $(this).click(function () {
                                    location.href = g;
                                    return false
                                })
                            }
                            break;
                        case 'viewfull':
                            var h = $(this);
                            $(this).click(function () {
                                var b = !G;
                                pause();
                                var c = $("img", h).attr("src");
                                var d = c.substring(c.length - 3, c.length);
                                c = c.substring(0, c.length - 4) + "_org." + d;
                                var e = $('.panel-overlay', h).html();
                                var a = $("<a href='" + c + "' title='" + e + "'>TEMP</a>");
                                var f = {
                                    imageLoading: F + '/lightbox/lightbox-ico-loading.gif',
                                    imageBtnPrev: F + '/lightbox/lightbox-btn-prev.gif',
                                    imageBtnNext: F + '/lightbox/lightbox-btn-next.gif',
                                    imageBtnClose: F + '/lightbox/lightbox-btn-close.gif',
                                    imageBlank: F + '/lightbox/lightbox-blank.gif'
                                };
                                if (b) {
                                    f.onClose = play
                                };
                                a.lightBox(f);
                                a.trigger('click')
                            });
                            break;
                        default:
                            break
                    }
                }
            });
            caption_overlay_padding = extraWidth($('.panel-overlay', bq));
            $('.panel-overlay', bq).css({
                'position': 'absolute',
                'zIndex': '999',
                'width': (z.panel_width - 2 * caption_overlay_padding) + 'px',
                'left': '0',
                'display': 'none'
            });
            if (z.show_captions) {
                overlayBackground = $("<div>");
                overlayBackground.appendTo(bq);
                overlayBackground.addClass('overlay-background');
                overlayBackground.css({
                    'position': 'absolute',
                    'z-index': 5000,
                    'opacity': z.overlay_opacity
                });
                overlayContent = $("<div>");
                overlayContent.appendTo(bq);
                overlayContent.addClass('overlay-content-panel');
                overlayContent.css({
                    'position': 'absolute',
                    'z-index': 5001,
                    'overflow': 'hidden'
                });
                if (z.overlay_position == 'top') {} else if (z.overlay_position == 'right') {
                    overlayContent.css('top', extraHeight($('.panel-overlay', bq)));
                    overlayBackground.css('top', '0px');
                    overlayContent.css('right', caption_overlay_padding + 'px');
                    overlayBackground.css('right', '0px');
                    overlayContent.css('left', 'auto');
                    overlayBackground.css('left', 'auto');
                    overlayContent.css('width', z.caption_thickness - caption_overlay_padding);
                    overlayBackground.css('width', z.caption_thickness);
                    overlayContent.css('height', z.panel_height - extraHeight($('.panel-overlay', bq)));
                    overlayBackground.css('height', z.panel_height - extraHeight($('.overlay-background', bq)));
                    overlayBackground.addClass('overlay-background-left')
                } else if (z.overlay_position == 'left') {
                    overlayContent.css('top', extraHeight($('.panel-overlay', bq)));
                    overlayBackground.css('top', 0);
                    overlayContent.css('left', 0);
                    overlayBackground.css('left', 0);
                    overlayContent.css('left', caption_overlay_padding + 'px');
                    overlayBackground.css('left', 'auto');
                    overlayContent.css('width', z.caption_thickness - caption_overlay_padding);
                    overlayBackground.css('width', z.caption_thickness);
                    overlayContent.css('height', z.panel_height - extraHeight($('.panel-overlay', bq)));
                    overlayBackground.css('height', z.panel_height - extraHeight($('.overlay-background', bq)) + 0 * 2);
                    overlayBackground.addClass('overlay-background-right')
                } else {}
            } if (z.panel_gradient) {
                var j = $("<div>");
                j.addClass("gallery_gradient");
                j.appendTo(bq);
                j.css({
                    'position': 'absolute',
                    'z-index': 500,
                    'width': L,
                    'height': M,
                    'top': '0px',
                    'left': '0px'
                });
                j.html("<div><div><div></div></div></div>");
                if (z.caption_outside) {
                    if (z.overlay_position == 'left') {
                        $("div:eq(1)", j).css({
                            'background-position': (f_caption_thickness) + 'px'
                        })
                    } else if (z.overlay_position == 'right') {
                        $("div:eq(2)", j).css({
                            'background-position': (L - f_caption_thickness - 18) + 'px'
                        })
                    }
                }
            }
            var k = Math.round(z.panel_width / z.slices);
            for (var i = 0; i < z.slices; i++) {
                if (i == z.slices - 1) {
                    bq.append($("<div class=\"bj-slice\"></div>").css({
                        left: k * i + 'px',
                        width: (z.panel_width - k * i) + 'px'
                    }))
                } else {
                    bq.append($("<div class=\"bj-slice\"></div>").css({
                        left: k * i + 'px',
                        width: k + 'px'
                    }))
                }
            }
        };

        function resetSlices() {
            var b = $('.bj-slice', bq);
            b.each(function () {
                var a = $(this);
                a.css({
                    background: 'none',
                    top: '0px',
                    opacity: 1
                })
            });
            if (z.show_filmstrip) enableFrameClicking()
        }
        function buildNextTitlePanel() {
            var a = $("<div>");
            a.addClass("next_title");
            a.appendTo(bq);
            a.css({
                'position': 'absolute',
                'z-index': 5001
            });
            switch (z.filmstrip_position) {
                case 'bottom':
                    a.css({
                        'bottom': '0px',
                        'padding-bottom': (T - 16) / 2 + 'px',
                        'padding-left': '23px'
                    });
                    break;
                case 'top':
                    a.css({
                        'top': (Q - 27) / 2 + 'px',
                        'padding-left': '23px'
                    });
                    break
            };
            final_caption_width = z.caption_thickness + extraWidth($('.panel-overlay', bu));
            switch (z.overlay_position) {
                case 'right':
                    a.css({
                        'right': '0px',
                        'width': (final_caption_width - z.frame_margin - 23) + 'px',
                        'height': T + 'px',
                        'overflow': 'hidden'
                    });
                    break;
                case 'left':
                    a.css({
                        'left': (final_caption_width + R + 54 + z.frame_gap * 2 + 2 * z.frame_margin) + 'px',
                        'width': (L - final_caption_width - R) + 'px',
                        'height': T + 'px',
                        'overflow': 'hidden'
                    });
                    break
            }
        }
        function buildFilmstrip() {
            br.wrap('<div class="strip_wrapper"></div>');
            if (E == 'strip') {
                bs.clone().appendTo(br);
                bs.clone().appendTo(br);
                bs = $('li', br)
            }
            br.css({
                'listStyle': 'none',
                'margin': '0',
                'padding': '0',
                'width': P + 'px',
                'position': 'absolute',
                'zIndex': '900',
                'top': (X == 'vertical' && E == 'strip' ? -((T + z.frame_gap) * B) : 0) + 'px',
                'left': (X == 'horizontal' && E == 'strip' ? -((S + z.frame_gap) * B) : 0) + 'px',
                'height': Q + 'px'
            });
            bs.css({
                'float': 'left',
                'position': 'relative',
                'height': T + 'px',
                'width': S + 'px',
                'zIndex': '901',
                'padding': '0',
                'cursor': 'pointer'
            });
            switch (z.filmstrip_position) {
                case 'top':
                    bs.css({
                        'marginBottom': W + 'px',
                        'marginRight': z.frame_gap + 'px'
                    });
                    break;
                case 'bottom':
                    bs.css({
                        'marginTop': W / 2 + 'px',
                        'marginRight': z.frame_gap + 'px'
                    });
                    break;
                case 'left':
                    bs.css({
                        'marginRight': W + 'px',
                        'marginBottom': z.frame_gap + 'px'
                    });
                    break;
                case 'right':
                    bs.css({
                        'marginLeft': W + 'px',
                        'marginBottom': z.frame_gap + 'px'
                    });
                    break
            }
            $('.img_wrap', bs).each(function (i) {
                $(this).css({
                    'height': z.frame_height + 'px',
                    'width': z.frame_width + 'px',
                    'position': 'relative',
                    'left': '0px',
                    'overflow': 'hidden'
                });
                $(this).append("<div class='number'>" + (i + 1) + "</div>");
                $(this).hover(function () {
                    $(this).addClass('img_wrap_hover');
                    if (z.show_next_item_title) showNextTitle(i)
                }, function () {
                    $(this).removeClass('img_wrap_hover');
                    if (z.show_next_item_title) showNextTitle(-1)
                })
            });
            $('img', bs).css({
                'marginLeft': '-1000px'
            });
            $('.number', bs).each(function (i) {
                $(this).css({
                    'float': 'left',
                    'margin': '6px 0 0 10px'
                });
                if (i > 8) {
                    $(this).css({
                        'margin': '6px 0 0 6px'
                    })
                }
            });
            $('img', bs).each(function (i) {
                $(this).css({
                    'opacity': z.frame_opacity,
                    'height': '0px',
                    'width': '0px',
                    'position': 'relative',
                    'top': '0px',
                    'left': '0px'
                }).mouseover(function () {
                    $(this).stop().animate({
                        'opacity': 1.0
                    }, 300)
                }).mouseout(function () {
                    if (!$(this).parent().parent().hasClass('current')) $(this).stop().animate({
                            'opacity': z.frame_opacity
                        }, 300)
                })
            });
            $('.strip_wrapper', bq).css({
                'position': 'absolute',
                'overflow': 'hidden',
                'z-index': 5002
            });
            var a = $("<div>");
            a.addClass("strip_background");
            a.appendTo(bq);
            a.css({
                'position': 'absolute',
                'z-index': 5001,
                'opacity': 0.5
            });
            f_caption_thickness = z.caption_thickness + extraWidth($('.panel-overlay', bu));
            if (X == 'horizontal') {
                $('.strip_wrapper', bq).css({
                    'top': (z.filmstrip_position == 'top' ? '2px' : (z.panel_height - Q) + 'px'),
                    'width': R + 'px',
                    'height': Q + 'px'
                });
                a.css({
                    'top': (z.filmstrip_position == 'top' ? '0px' : z.panel_height - Q + 'px'),
                    'left': '0px',
                    'width': L + 'px',
                    'height': Q + 'px'
                });
                a.addClass('strip_background_' + z.filmstrip_position);
                switch (z.overlay_position) {
                    case 'left':
                        $('.strip_wrapper', bq).css({
                            'left': f_caption_thickness + z.frame_gap + 27 + z.frame_margin + 'px'
                        });
                        break;
                    case 'right':
                        $('.strip_wrapper', bq).css({
                            'right': f_caption_thickness + z.frame_gap + 27 + z.frame_margin + 'px'
                        });
                        break
                }
            } else {
                $('.strip_wrapper', bq).css({
                    'left': (z.filmstrip_position == 'left' ? Math.max(0, W) + 'px' : L - P + 'px'),
                    'top': Math.max(0, z.frame_gap) + 'px',
                    'width': P + 'px',
                    'height': wrapper_height + 'px'
                })
            }
            if (z.show_next_item_title) buildNextTitlePanel();
            var b = $('<div></div>');
            b.addClass('pointer').appendTo(bq).css({
                'position': 'absolute',
                'zIndex': '1001',
                'width': '0px',
                'fontSize': '0px',
                'lineHeight': '0%',
                'borderTopWidth': N + 'px',
                'borderRightWidth': (O / 2) + 'px',
                'borderBottomWidth': N + 'px',
                'borderLeftWidth': (O / 2) + 'px',
                'borderStyle': 'solid'
            });
            var c = $.browser.msie && $.browser.version.substr(0, 1) == '6' ? 'pink' : 'transparent';
            if (!z.show_panels) {
                b.css('borderColor', c)
            };
            switch (z.filmstrip_position) {
                case 'top':
                    b.css({
                        'top': T + 0 + 'px',
                        'left': L - R - f_caption_thickness + 0 + ((S / 2) - (O / 2)) + 'px',
                        'borderBottomColor': c,
                        'borderRightColor': c,
                        'borderLeftColor': c
                    });
                    break;
                case 'bottom':
                    b.css({
                        'top': (z.panel_height - (N * 2) - T + 0) + 'px',
                        'left': L - R - f_caption_thickness + 0 - 27 - z.frame_gap + ((S / 2) - (O / 2)) + 'px',
                        'borderTopColor': c,
                        'borderRightColor': c,
                        'borderLeftColor': c
                    });
                    break;
                case 'left':
                    b.css({
                        'right': (z.panel_width - O + 0 + W - P) + 'px',
                        'top': (T / 2) - (N) + (E == 'strip' ? 0 : ((T + z.frame_gap) * B)) + 0 + 'px',
                        'borderBottomColor': c,
                        'borderRightColor': c,
                        'borderTopColor': c
                    });
                    break;
                case 'right':
                    b.css({
                        'left': (z.panel_width - O + 0 + W - P) + 'px',
                        'top': (T / 2) - (N) + (E == 'strip' ? 0 : ((T + z.frame_gap) * B)) + 0 + 'px',
                        'borderBottomColor': c,
                        'borderLeftColor': c,
                        'borderTopColor': c
                    });
                    break
            }
            bv = $('.pointer', bq);
            var d = $('<img />');
            d.addClass('nav-next').attr('src', F + '/next.png').appendTo(bq).css({
                'position': 'absolute',
                'cursor': 'pointer',
                'z-index': 5002
            }).click(showNextItem);
            var e = $('<img />');
            e.addClass('nav-prev').attr('src', F + '/prev.png').appendTo(bq).css({
                'position': 'absolute',
                'cursor': 'pointer',
                'z-index': 5002
            }).click(showPrevItem);
            if (X == 'horizontal') {
                d.css({
                    'top': (z.filmstrip_position == 'top' ? 0 + Q / 2 - 1 : z.panel_height - Q / 2 + 0) - (T / 2) + 'px'
                });
                e.css({
                    'top': (z.filmstrip_position == 'top' ? 0 + Q / 2 - 1 : z.panel_height - Q / 2 + 0) - (T / 2) + 'px'
                });
                if (z.overlay_position == 'right') {
                    d.css({
                        'right': f_caption_thickness + 0 + z.frame_margin + 'px'
                    });
                    e.css({
                        'right': f_caption_thickness + 0 + R + 27 + z.frame_gap * 2 + z.frame_margin + 'px'
                    })
                } else if (z.overlay_position == 'left') {
                    d.css({
                        'left': (f_caption_thickness + 0 + R + 27 + z.frame_gap * 2 + z.frame_margin) + 'px'
                    });
                    e.css({
                        'left': (f_caption_thickness + 0 + z.frame_gap * 2 - z.frame_margin) + 'px'
                    })
                }
            } else {
                d.css({
                    'left': (z.filmstrip_position == 'left' ? Math.max(0, W) : z.panel_width + W + 0 - P) + ((S - 22) / 2) + 13 + 'px',
                    'top': wrapper_height + (Math.max(0, z.frame_gap) * 2) + 'px'
                });
                e.css({
                    'left': (z.filmstrip_position == 'left' ? Math.max(0, W) : z.panel_width + W + 0 - P) + ((S - 22) / 2) - 13 + 'px',
                    'top': wrapper_height + (Math.max(0, z.frame_gap) * 2) + 'px'
                })
            }
            if (z.show_filmstrip && z.auto_hide_filmstrip) {
                I = true;
                $('.strip_background', bq).animate({
                    top: (z.filmstrip_position == 'top' ? (-Q) + 'px' : z.panel_height + 'px')
                });
                $('.strip_wrapper', bq).animate({
                    top: (z.filmstrip_position == 'top' ? (-Q - 2) + 'px' : z.panel_height + 'px')
                });
                $('.nav-next,.nav-prev', bq).animate({
                    top: (z.filmstrip_position == 'top' ? (-Q) : z.panel_height + Q / 2) - (T / 2) + 'px'
                });
                $('.next_title', bq).animate({
                    top: (z.filmstrip_position == 'top' ? Math.max(0, W) + Q / 2 : z.panel_height - Q / 2) - (T / 2) + 'px'
                })
            }
            br.removeClass("hide")
        };

        function mouseIsOverGallery(x, y) {
            var a = getPos(bq[0]);
            var b = a.top + V;
            var c = a.left + V;
            return x > c && x < c + L + (X == 'horizontal' ? (0 * 2) : 0 + Math.max(0, W)) && y > b && y < b + M + (X == 'vertical' ? (0 * 2) : 0 + Math.max(0, W))
        };

        function getInt(i) {
            i = parseInt(i, 10);
            if (isNaN(i)) {
                i = 0
            }
            return i
        }
        function buildGallery() {
            if (!K) {
                K = true;
                var a = z.show_filmstrip ? $('img', bs) : $('img', bu);
                bq.parent().css({
                    'width': L + (V * 2) + 'px',
                    'height': M + (V * 2) + 'px',
                    'position': 'relative'
                });
                bq.css({
                    'width': L + 'px',
                    'height': M + 'px',
                    'overflow': 'hidden',
                    'left': V + 'px',
                    'top': V + 'px'
                });
                if (z.show_filmstrip) {
                    buildFilmstrip();
                    enableFrameClicking()
                }
                if (z.show_controller) {
                    var b = $('<img />');
                    b.addClass('controller').addClass('playing').attr('src', F + 'pause.png').appendTo(bq).css({
                        'position': 'absolute',
                        'cursor': 'pointer',
                        'z-index': 1001,
                        'top': M / 2 - 26,
                        'opacity': 0
                    }).click(play);
                    if (!z.show_captions) {
                        b.css({
                            'left': L / 2 - 26
                        })
                    } else {
                        f_caption_thickness = z.caption_thickness + extraWidth($('.panel-overlay', bu));
                        pos = (L - f_caption_thickness) / 2 + 0 - 26;
                        if (z.overlay_position == 'left') {
                            pos = (L + f_caption_thickness) / 2 + 0 - 26
                        }
                        b.css({
                            'left': pos + 'px'
                        })
                    }
                    b.wrap("<div></div>");
                    b.parent().css({
                        'zoom': 1
                    })
                }
                if (z.show_panels) {
                    buildPanels()
                }
                $(bq).mouseover(function () {
                    $(this).addClass("mouseover")
                }).mouseout(function () {
                    if (!mouseIsOverGallery(bx, mouseY)) {
                        $(this).removeClass("mouseover")
                    }
                });
                $(document).mousemove(function (e) {
                    bx = e.pageX;
                    mouseY = e.pageY;
                    if (bq.hasClass("mouseover") && mouseIsOverGallery(e.pageX, e.pageY)) {
                        if (z.show_panels && z.show_controller) {
                            if (!b) {
                                b = true;
                                $('.controller', bq).animate({
                                    opacity: 0.5
                                }, 500)
                            }
                        }
                        if (z.show_panels && z.pause_on_hover) {
                            if (!G) {
                                $(document).oneTime(500, "animation_pause", function () {
                                    $(document).stopTime("transition");
                                    G = true
                                })
                            }
                        }
                        if (z.show_panels && !z.show_filmstrip && !bp) {
                            $('.nav-next-overlay,.nav-prev-overlay,.nav-next,.nav-prev').fadeIn('fast');
                            bp = true
                        }
                        if (z.show_filmstrip && z.auto_hide_filmstrip) {
                            if (I) {
                                I = false;
                                $('.strip_background', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? (0) + 'px' : M + 0 - Q + 'px')
                                });
                                $('.strip_wrapper', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? (0 + 2) + 'px' : M + 0 - Q + 'px')
                                });
                                $('.nav-next,.nav-prev', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? 0 + Q / 2 : M + 0 - Q / 2) - T / 2 + 'px'
                                });
                                $('.next_title', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? 0 + Q / 2 : M + 0 - Q / 2 - 2) - T / 2 + 'px'
                                })
                            }
                        }
                    } else {
                        if (z.show_panels && z.show_controller) {
                            if (b) {
                                b = false;
                                $('.controller', bq).animate({
                                    opacity: 0
                                }, 500)
                            }
                        }
                        if (z.show_panels && z.pause_on_hover) {
                            $(document).stopTime("animation_pause");
                            if (G) {
                                $(document).everyTime(z.transition_interval, "transition", function () {
                                    showNextItem()
                                });
                                G = false
                            }
                        }
                        if (z.show_panels && !z.show_filmstrip && bp) {
                            $('.nav-next-overlay,.nav-prev-overlay,.nav-next,.nav-prev').fadeOut('fast');
                            bp = false
                        }
                        if (z.show_filmstrip && z.auto_hide_filmstrip) {
                            if (!I) {
                                I = true;
                                $('.strip_background,.strip_wrapper', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? (-Q) + 'px' : z.panel_height + 0 * 2 + 'px')
                                });
                                $('.nav-next,.nav-prev', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? (-Q / 2) : z.panel_height + Q / 2 + 2 * 0) - (T / 2) + 'px'
                                });
                                $('.next_title', bq).animate({
                                    top: (z.filmstrip_position == 'top' ? (-Q / 2) : z.panel_height + Q / 2 + 2 * 0 - 2) - (T / 2) + 'px'
                                })
                            }
                        }
                    }
                });
                $('.loader', bq).fadeOut('1000', function () {
                    B = C - 1;
                    showItem(0);
                    if (C > 1 && z.play_at_first) {
                        $(document).everyTime(z.transition_interval, "transition", function () {
                            showNextItem()
                        })
                    } else {
                        $('.controller', bq).attr('src', F + 'play.png');
                        $('.controller', bq).removeClass('playing').addClass('paused');
                        G = true
                    }
                });
                $('.panels', bq).css({
                    'visibility': 'visible'
                });
                br.css('visibility', 'visible')
            }
        }
        function showNextTitle(i) {
            if (i > -1) {
                window.clearTimeout(bw);
                $('.next_title', bq).html($('.overlay-title', bu.eq(i % C)).html());
                $('.next_title', bq).addClass("next_title_over")
            } else {
                bw = window.setTimeout(function () {
                    $('.next_title', bq).fadeOut(500).html("").fadeIn(100);
                    $('.next_title', bq).removeClass("next_title_over")
                }, 500)
            }
        }
        return this.each(function () {
            $(this).wrap("<div></div>");
            $(this).parent().wrap("<div class=\"gallery_out\"></div>");
            bq = $(this).parent();
            bq.attr('id', $(this).attr('id')).addClass('gallery').prepend("<div class='panels'></div>");
            bq.parent().attr('id', $(this).attr('id') + '_out');
            V = z.gallery_padding;
            bq.css({
                'height': (z.panel_height) + 'px',
                'padding': '0px'
            });
            $('.panels', bq).css({
                'position': 'relative',
                'visibility': 'hidden'
            });
            $(this).removeAttr('id').addClass('filmstrip');
            $(document).stopTime("transition");
            $(document).stopTime("animation_pause");
            A = bq.attr('id');
            bo = $('.panel-content', bq).length == 0;
            N = z.pointer_size;
            O = z.pointer_size * 2;
            X = (z.filmstrip_position == 'top' || z.filmstrip_position == 'bottom' ? 'horizontal' : 'vertical');
            if (X == 'vertical') z.show_captions = false;
            W = (z.show_panels ? 6 : 0);
            L = z.panel_width;
            M = z.panel_height;
            galleryPos = getPos(bq[0]);
            $('<div>').addClass('loader').css({
                'position': 'absolute',
                'zIndex': '32666',
                'opacity': 0.7,
                'top': '0px',
                'left': '0px',
                'width': L + (X == 'horizontal' ? (0 * 2) : 0 + Math.max(0, W)) + 'px',
                'height': M + (X == 'vertical' ? (0 * 2) : 0 + Math.max(0, W)) + 'px'
            }).appendTo(bq);
            $('script').each(function (i) {
                var s = $(this);
                if (s.attr('src') && s.attr('src').match(/jquery\.galleryview/)) {
                    loader_path = s.attr('src').split('jquery.galleryview')[0];
                    F = loader_path + '../../../themes/'
                }
            });
            br = $('.filmstrip', bq);
            bs = $('li', br);
            bs.addClass('frame');
            if (z.show_panels) {
                for (i = 0; i < bs.length; i++) {
                    if (bs.eq(i).find('.panel-content').length > 0) {
                        bs.eq(i).find('.panel-content').remove().prependTo(bq).addClass('panel')
                    } else {
                        p = $('<div>');
                        p.addClass('panel');
                        var a = new Image();
                        if (z.caption_outside) {
                            $(a).css({
                                'width': (z.panel_width - z.caption_thickness - 38) + 'px',
                                'height': (z.panel_height) + 'px'
                            });
                            if (z.overlay_position == 'left') {
                                $(a).css({
                                    'marginLeft': (z.caption_thickness + 38) + 'px'
                                })
                            }
                        }
                        var b = bs.eq(i).find('img.img').eq(0).attr('title');
                        var c = bs.eq(i).find('img.img').eq(0).attr('alt');
                        $(a).load(function () {
                            J = true;
                            buildGallery()
                        }).attr('src', b).attr('alt', c).appendTo(p);
                        p.hide();
                        p.appendTo($('.panels', bq));
                        if (z.show_captions) {
                            bs.eq(i).find('.panel-overlay').remove().appendTo(p)
                        } else {
                            bs.eq(i).find('.panel-overlay').hide().appendTo(p)
                        }
                    }
                }
            } else {
                $('.panel-overlay', bs).remove();
                $('.panel-content', bs).remove()
            }
            if (!z.show_filmstrip) {
                br.remove()
            } else {
                bs.each(function (i) {
                    if ($(this).find('a').length > 0) {
                        $(this).find('a').wrap('<div class="img_wrap"></div>')
                    } else {
                        $(this).find('img').wrap('<div class="img_wrap"></div>')
                    }
                });
                bt = $('.img_wrap', bs)
            }
            bu = $('.panel', bq);
            if (!z.show_panels) {
                z.panel_height = 0;
                z.panel_width = 0
            }
            S = z.frame_width + extraWidth(bt);
            T = z.frame_height + extraHeight(bt);
            C = z.show_panels ? bu.length : bs.length;
            if (X == 'horizontal') {
                strip_size = Math.min(C, z.filmstrip_size)
            } else {
                strip_size = z.show_panels ? Math.floor((z.panel_height - (z.frame_gap + 22)) / (T + z.frame_gap)) : Math.min(C, z.filmstrip_size)
            }
            if (strip_size >= C) {
                E = 'pointer';
                strip_size = C
            } else {
                E = 'strip'
            }
            item_showing_max = strip_size - 1;
            br.css('margin', '0px');
            if (X == 'horizontal') {
                if (E == 'pointer') {
                    P = (S * C) + (z.frame_gap * (C))
                } else {
                    P = (S * C * 3) + (z.frame_gap * (C * 3))
                }
            } else {
                P = (S + W)
            }
            if (X == 'horizontal') {
                Q = (T + W)
            } else {
                if (E == 'pointer') {
                    Q = (T * C + z.frame_gap * (C))
                } else {
                    Q = (T * C * 3) + (z.frame_gap * (C * 3))
                }
            }
            R = ((strip_size * S) + ((strip_size - 1) * z.frame_gap));
            wrapper_height = ((strip_size * T) + ((strip_size - 1) * z.frame_gap))
        })
    };
    $.fn._reverse = [].reverse
})(jQuery);